import { nextTick } from 'vue'
import { createRouter, createWebHistory } from "vue-router"
import { routes } from './componentIndex'
import hljs from 'highlight.js'

const router = createRouter({
    history: createWebHistory(),
    routes
})
let contentEl = null
router.afterEach(() => {
    nextTick(() => {
        if (contentEl == null) {
            contentEl = window.document.getElementsByClassName('content')[0]
        }
        let els = contentEl.querySelectorAll('pre code')
        els.forEach(a => {
            hljs.highlightElement(a)
        })
    })
})
export default router